home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _4F9F0DBFD5B14C4D853D1ED95A0194DF < prev    next >
Text File  |  2005-04-19  |  1KB  |  47 lines

  1. ///basic particle shader
  2. //input should be 4 points that are the same, tex coord will expand them in screen space
  3. //3rd component of tex coord is size of particle
  4. //Luke Lenhart
  5. //(C)2004-2005 Digipen Institute of Technology
  6.  
  7. //view,projection transform
  8. float4x4 matViewProj;
  9.  
  10. //camera position in world space
  11. float4 cameraPos;
  12.  
  13. //shader input
  14. struct VS_INPUT
  15. {
  16.     float4 Pos : POSITION;
  17.     float4 Color : COLOR;
  18.     float3 Tex0 : TEXCOORD0;
  19. };
  20.  
  21. //shader output
  22. struct VS_OUTPUT
  23. {
  24.     float4 Pos : POSITION;
  25.     float4 Color : COLOR;
  26.     float2 Tex0 : TEXCOORD0;
  27. };
  28.  
  29. //shader code
  30. VS_OUTPUT VShader(VS_INPUT In)
  31. {
  32.     VS_OUTPUT Out;
  33.     
  34.     //transform pos and copy tex coord and color over
  35.     Out.Pos=mul(matViewProj,In.Pos);
  36.     Out.Tex0.xy=In.Tex0.xy;
  37.     Out.Color=In.Color;
  38.     
  39.     //expand outwards from center point, based on distance and tex coord
  40.     float dist=distance(cameraPos.xyz,In.Pos.xyz);
  41.     
  42.     Out.Pos.xy+=(1.0f/sqrt(dist))*(In.Tex0-0.5f)*In.Tex0.z;
  43.  
  44.     //spit out the results
  45.     return Out;
  46. }
  47.